#pragma once
#include <Windows.h>
#include <string>
#include "../locker.h"

class GroupClientEvent {
public:
    virtual void OnRecvData(const sockaddr_in *pFromAddr, const std::string &strRecved, std::string &strResp) = 0;
};

class CGroupClient {
public:
    CGroupClient();
    virtual ~CGroupClient();

    bool Start(const std::string &strGroupIp, USHORT nGroupPort, GroupClientEvent *pListener);
    bool SendData(const std::string &strData);
    void Stop();
private:
    static DWORD WINAPI RecvThread(LPVOID pParam);

private:
    bool m_bInitSuccess;
    HANDLE m_hRecvThread;
    UINT_PTR m_nClientSocket;
    std::string m_strGroupIp;
    USHORT m_nGroupPort;

    GroupClientEvent *m_pListener;
};